﻿<Window x:Class="EmlViewer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:emlViewer="clr-namespace:EmlViewer"
        xmlns:behaviours="clr-namespace:EmlViewer.Behaviours"
        xmlns:controls="clr-namespace:EmlViewer.Controls"
        Title="{x:Static emlViewer:Constants.ApplicationTitle}" 
        Height="550" Width="825"
        WindowStartupLocation="CenterScreen"
        AllowDrop="True"
        Icon="MC900435245.PNG"
        Background="{StaticResource Vbrush}"
        DataContext="{StaticResource ViewModel}"
        >
    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="File"  IsEnabled="False"/>
            <MenuItem Header="Edit"  IsEnabled="False"/>
            <MenuItem Header="View"  IsEnabled="False"/>
            <MenuItem Header="Go"    IsEnabled="False"/>
            <MenuItem Header="Tools" IsEnabled="False" >
                <MenuItem Header="Export to XML" IsEnabled="False"/>
                <MenuItem Header="Detach and save attachments" IsEnabled="False"/>
            </MenuItem>
            <MenuItem IsEnabled="False">
                <MenuItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Search"  VerticalAlignment="Center"/>
                        <Rectangle Width="10"/>
                        <ComboBox Width="140"/>
                    </StackPanel>
                </MenuItem.Header>
            </MenuItem>
            <MenuItem Header="Help" Background="PaleGreen">
                <MenuItem Header="About" Command="{Binding HelpAboutCommand}"></MenuItem>
            </MenuItem> 
        </Menu>
        <Border DockPanel.Dock="Top" BorderBrush="DeepSkyBlue" BorderThickness="3">
            <Border.ToolTip>
                <TextBlock Foreground="Wheat" Text="Drag and drop 'eml' files into this area.  Directories can also be dropped here."/>
            </Border.ToolTip>
            <Grid AllowDrop="True" 
                  behaviours:DropBehaviour.DandFiles="{Binding LoadFilesCommand}" 
                  behaviours:DropBehaviour.DandDirectories="{Binding LoadDirectoriesCommand}" 
                  Background="{StaticResource Vbrush}" >
                <DockPanel>
                    <TextBlock DockPanel.Dock="Top" Text="Drop Zone" FontSize="24"/>
                    <Rectangle DockPanel.Dock="Top" Height="15"/>
                    <TextBlock DockPanel.Dock="Top" Text="Drag and drop 'eml' files here"  />
                    <Rectangle DockPanel.Dock="Top" Height="10"/>
                </DockPanel>
            </Grid>
        </Border>
        <StatusBar DockPanel.Dock="Bottom" AllowDrop="False">
            <TextBlock Text="{Binding ItemCountText}" Width="90" ToolTip="Number of items"/>
            <TextBlock Text="{Binding ErrorCountText}" Width="90" >
                <TextBlock.Style>
                    <Style TargetType="TextBlock">
                        <Setter Property="Foreground" Value="Red"/>
                        <Setter Property="ToolTip" Value="There were some problems"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ExceptionInfos.Count}" Value="0">
                                <Setter Property="Foreground" Value="Black"/>
                                <Setter Property="ToolTip" Value=""/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
            </TextBlock>
            <StatusBarItem HorizontalAlignment="Right">
                <StackPanel Orientation="Horizontal" >
                    <Button Content="Close child windows" Command="{Binding CloseChildWindowsCommand}">
                        <Button.ToolTip>
                            <TextBlock Foreground="Wheat" Text="Close all open message windows"/>
                        </Button.ToolTip>
                    </Button>
                    <Rectangle Width="15"/>
                    <Button Content="Clear list" Command="{Binding ClearCommand}">
                        <Button.ToolTip>
                            <TextBlock Foreground="Wheat" Text="Clear all items"/>
                        </Button.ToolTip>
                    </Button>
                    <Rectangle Width="15"/>
                </StackPanel>
            </StatusBarItem>
        </StatusBar>
        <TabControl DockPanel.Dock="Top" AllowDrop="False">
            <!--<TabControl.Style>
                <Style TargetType="TabControl">
                    <Setter Property="Visibility" Value="Collapsed"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding HaveItems}" Value="True">
                            <Setter Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </TabControl.Style>-->
            <TabItem Header="Emails" Background="Transparent">
                <DockPanel Background="Transparent">
                    <controls:TextBlockPanelHeader DockPanel.Dock="Top" Text="Messages" AllowDrop="False"/>
                    <DataGrid DockPanel.Dock="Top" 
                              Background="{StaticResource CustomGradientSkyFall}"
                              Foreground="Wheat"
                              FontWeight="Bold"
                              RowBackground="Transparent"
                              AlternatingRowBackground="Transparent"
                              ItemsSource="{Binding MessageInfos}"
                              IsSynchronizedWithCurrentItem="True"
                              IsReadOnly="True"
                              SelectionMode="Single"
                              SelectionUnit="FullRow"
                              SelectedValue="{Binding VmSelectedMessageInfo}"
                              behaviours:DoubleClickBehaviour.DataGridDoubleClick="{Binding ViewContentCommand}"
                          >
                        <DataGrid.ToolTip>
                            <TextBlock Foreground="Wheat" Text="This area gives summary information for each item"/>
                        </DataGrid.ToolTip>
                    </DataGrid>
                </DockPanel>
            </TabItem>
            <TabItem Header="Exceptions" Background="Transparent">
                <DockPanel>
                    <controls:TextBlockPanelHeader DockPanel.Dock="Top" Text="Issues encountered"/>
                    <DataGrid DockPanel.Dock="Top"
                              ItemsSource="{Binding ExceptionInfos}"
                              IsSynchronizedWithCurrentItem="True"
                              IsReadOnly="True"
                              SelectionMode="Single"
                              SelectionUnit="FullRow"
                              Background="{StaticResource CustomGradientSkyFall}"
                              Foreground="Wheat"
                              FontWeight="Bold"
                              RowBackground="Transparent"
                              AlternatingRowBackground="Transparent"
                          >
                    </DataGrid>
                </DockPanel>
            </TabItem>
        </TabControl>
    </DockPanel>
</Window>
